﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.ProductFAQ;
using DataAccess.ProductFAQ;
namespace Bussiness.ProductFAQ
{
    public class ProductFAQBLL
    {
        private ProductFAQDAL dal;
        public ProductFAQBLL()
        {
            dal = new ProductFAQDAL();
        }
        public List<ProductFAQModels> getfaqbyproid(int ProductID, int langid)
        {
            List<ProductFAQModels> list = new List<ProductFAQModels>();
            ProductFAQModels fur;
            DataTable tb = dal.getfaqbyproid(ProductID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new ProductFAQModels();
                    fur.ProductFAQID = int.Parse(row[0].ToString());
                    fur.FAQTitles = row[6].ToString();
                    fur.FAQAnwers = row[7].ToString();
                    fur.ProductID = int.Parse(row[3].ToString());
                    fur.FlagImage = row[11].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public ProductFAQModels getfaqbyid(int ProductFAQID, int langid)
        {

            ProductFAQModels fur = new ProductFAQModels();
            DataTable tb = dal.getfaqbyid(ProductFAQID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.ProductFAQID = int.Parse(row[0].ToString());
                    fur.FAQTitles = row[6].ToString();
                    fur.FAQAnwers = row[7].ToString();
                    fur.ProductID = int.Parse(row[3].ToString());

                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public ProductFAQModels gettop1faq()
        {

            ProductFAQModels fur = new ProductFAQModels();
            DataTable tb = dal.gettop1faq();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.ProductFAQID = int.Parse(row[0].ToString());
                    fur.FAQTitles = row[1].ToString();

                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int UpdateFAQ(ProductFAQModels models, int langid)
        {
            if (dal.UpdateFAQ(models) > 0 && dal.UpdateFAQLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertFAQ(ProductFAQModels models)
        {
            if (dal.InsertFAQ(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertFAQLang(ProductFAQModels models, int langid)
        {
            if (dal.InsertFAQLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteFAQ(int ProductFAQID)
        {
            if (dal.DeleteFAQLang(ProductFAQID) > 0 && dal.DeleteFAQ(ProductFAQID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }


    }
}
